import { imagesUrl } from "@/utils/baseUrl";
import { Image, Text, View } from "@tarojs/components";
import Taro, { useDidShow, useDidHide, useRouter } from "@tarojs/taro";
import { observer } from "mobx-react";
import { useEffect } from "react";

function NetWorkError() {
  // 可以使用所有的 React Hooks
  // useEffect(() => {
  //   console.log("netWorkError useEffect");
  // });

  //获取路由
  let route = useRouter();
  console.log(route);
  let redirectPath = route.params.form || "/pages/home/index";

  // 对应 onShow
  useDidShow(() => {
    console.log("netWorkError useDidShow");
  });
  // 对应 onHide
  useDidHide(() => {
    console.log("netWorkError useDidHide");
  });
  return (
    <View className="h-screen bg-x_bg overflow-hidden">
      <Image
        src={imagesUrl + "404.png"}
        className="block w-105 h-161 mx-auto mt-198"
      ></Image>
      <Text className="block text-14 text-center text-black mx-auto mt-26">
        网络有点小问题
      </Text>
      <Image
        src={imagesUrl + "btn-refresh.png"}
        className="block w-130 h-48 mx-auto mt-26"
        onClick={() => {
          Taro.switchTab({
            url: redirectPath + "?from='networkError'&event='refresh'",
          });
        }}
      ></Image>
    </View>
  );
}
export default observer(NetWorkError);
